package Demo;

/**
 * Created with Interllij IDEA.
 * Descriptiption:多态
 * User: 王澄慧
 * Date: 2022-04-09
 * Time: 9:27
 */


class Sharp{
    public void draw(){
        System.out.println("画图形");
    }
}
class Cycle extends Sharp{
    @Override
    public void draw() {
        System.out.println("○");
    }
}
class Rect extends Sharp{
    @Override
    public void draw() {
        System.out.println("◆");
    }
}
class San extends Sharp{
    @Override
    public void draw() {
        System.out.println("△");
    }
}
class Flalor extends Sharp{
    @Override
    public void draw() {
        System.out.println("花");
    }
}
public class TestDemo2 {
    public static void drawMar(){
        Cycle cycle = new Cycle();
        Rect rect = new Rect();
        San san = new San();
        Flalor flalor = new Flalor();
        Sharp [] sharps = {cycle,rect,cycle,rect,flalor,san};
        for (Sharp sharp:sharps) {
            sharp.draw();
        }
    }

    public static void main(String[] args) {
        drawMar();
    }
    public static void DrawMaek(Sharp sharp){
        sharp.draw();
    }

    public static void main2(String[] args) {
        Cycle cycle = new Cycle();
        Rect rect = new Rect();
        San san = new San();
        DrawMaek(cycle);
        DrawMaek(rect);
        DrawMaek(san);
        DrawMaek(new Flalor());
    }
    public static void main1(String[] args) {
        Sharp sharp = new Cycle();
        Sharp sharp1 = new Rect();
        sharp1.draw();
        sharp.draw();
    }
}
